#!bin/bash

if [ -n "$1" ] ; then
  data_date=$1
else 
  data_date=`date -d '-1 days' +%F`
fi

ODS_ADS_LOG_INC_SQL="
LOAD DATA INPATH '/warehouse/app_logs/${data_date}'
    OVERWRITE INTO TABLE jtp_ads_warehouse.ods_ads_log_inc PARTITION (dt = '${data_date}')
;
"

ODS_ADS_INFO_FULL_SQL="
LOAD DATA INPATH '/warehouse/app_logs/ads/${data_date}' OVERWRITE INTO TABLE
    jtp_ads_warehouse.ods_ads_info_full PARTITION (dt = '${data_date}')
;
"

ODS_ADS_PLATFORM_FULL_SQL="
LOAD DATA INPATH '/warehouse/app_logs/ads_platform/${data_date}' OVERWRITE INTO TABLE
    jtp_ads_warehouse.ods_ads_platform_full PARTITION (dt = '${data_date}')
;
"

ODS_ADS_PLATFORM_INFO_FULL_SQL="
LOAD DATA INPATH '/warehouse/app_logs/platform_info/${data_date}' OVERWRITE INTO TABLE
    jtp_ads_warehouse.ods_ads_platform_info_full PARTITION (dt = '${data_date}')
;
"

ODS_ADS_PRODUCT_INFO_FULL_SQL="
LOAD DATA INPATH '/warehouse/app_logs/product/${data_date}' OVERWRITE INTO TABLE
    jtp_ads_warehouse.ods_ads_product_info_full PARTITION (dt = '${data_date}')
;
"

/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ODS_ADS_LOG_INC_SQL}${ODS_ADS_INFO_FULL_SQL}${ODS_ADS_PLATFORM_FULL_SQL}${ODS_ADS_PLATFORM_INFO_FULL_SQL}${ODS_ADS_PRODUCT_INFO_FULL_SQL}"

